package com.example.smartcanteen.controller;

import com.example.smartcanteen.model.Student;
import com.example.smartcanteen.service.StudentService;
import com.example.smartcanteen.utils.ResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/studenT")
@CrossOrigin
public class StudentController {
    @Autowired
    private StudentService studentService;


    //所需数据：String：username；String：password；
    @PostMapping("/login")
    public ResponseMessage login(Student student) {


        return studentService.login(student);

    }


    //所需数据：String：username；String：password；String：newpassword；
    @PostMapping("/update")
    ResponseMessage update(Student student, String newpassword) {


        return studentService.update(student, newpassword);
    }

}
